home *** CD-ROM | disk | FTP | other *** search
- Imports System.ComponentModel
- Imports System.Web.UI
-
- <ToolboxData("<{0}:TableControl runat=server></{0}:TableControl>")> _
- Public Class TableControl
- Inherits System.Web.UI.WebControls.WebControl
-
- ' the CellBorderStile property shows how an enumerated
- ' property appears in the Properties window at design time
- ' (this property is ignored in the HTML generation)
- Dim m_CellBorderStyle As System.Web.UI.WebControls.BorderStyle
-
- <Description("The border style of table cells")> _
- Property CellBorderStyle() As System.Web.UI.WebControls.BorderStyle
- Get
- Return m_CellBorderStyle
- End Get
- Set(ByVal Value As System.Web.UI.WebControls.BorderStyle)
- m_CellBorderStyle = Value
- End Set
- End Property
-
- ' The Rows property
-
- Dim m_Rows As Integer = 3
-
- <Bindable(True), Category("Appearance"), DefaultValue(3), _
- Description("The number of rows")> _
- Property Rows() As Integer
- Get
- Return m_Rows
- End Get
- Set(ByVal Value As Integer)
- If Value > 0 Then
- m_Rows = Value
- End If
- End Set
- End Property
-
- ' The Columns property
-
- Dim m_Columns As Integer = 4
-
- <Bindable(True), Category("Appearance"), DefaultValue(4), _
- Description("The number of columns")> _
- Property Columns() As Integer
- Get
- Return m_Columns
- End Get
- Set(ByVal Value As Integer)
- If Value > 0 Then
- m_Columns = Value
- End If
- End Set
- End Property
-
- ' This method is where we actually send the output to the client
-
- Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
- Dim r, c As Integer
-
- ' create the <table> tag
- output.AddAttribute("border", "1")
- output.RenderBeginTag("table")
- output.WriteLine()
- output.Indent += 1
-
- ' render each table row
- For r = 1 To Rows
- output.RenderBeginTag("tr")
- output.WriteLine()
- output.Indent += 1
- ' render each column on the row
- For c = 1 To Columns
- output.RenderBeginTag("td")
- output.Write(r.ToString & "," & c.ToString)
- output.RenderEndTag()
- output.WriteLine()
- Next
- ' output a closing tag </TR>
- output.Indent -= 1
- output.RenderEndTag()
- output.WriteLine()
- Next
- ' output a closing tag </TABLE>
- output.Indent -= 1
- output.RenderEndTag()
- End Sub
-
- ' The ImageUrl property demonstrates how you can re-use a property
- ' editor defined in the framework
- ' (This property is ignored during HTML code generation)
- Dim m_ImageUrl As String
-
- <EditorAttribute("System.Web.UI.Design.ImageUrlEditor, System.Design, " _
- & "Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", GetType(System.Drawing.Design.UITypeEditor))> _
- Property ImageUrl() As String
- Get
- Return m_ImageUrl
- End Get
- Set(ByVal Value As String)
- m_ImageUrl = Value
- End Set
- End Property
-
- ' The CellFont property demonstrates that a FontInfo property
- ' inherits the editor defined in the framework
- ' (This property is ignored during HTML code generation)
-
- Dim m_CellFont As System.Web.UI.WebControls.FontInfo = MyBase.Font
-
- Property CellFont() As System.Web.UI.WebControls.FontInfo
- Get
- Return m_CellFont
- End Get
- Set(ByVal Value As System.Web.UI.WebControls.FontInfo)
- m_CellFont = Value
- End Set
- End Property
-
- ' The BackColor property shows how you can override a property
- ' with the only goal of hiding it in the Properties window
-
- <Browsable(False)> _
- Overrides Property BackColor() As System.Drawing.Color
- Get
- Return System.Drawing.Color.White
- End Get
- Set(ByVal Value As System.Drawing.Color)
- ' Ignore this assignment.
- End Set
- End Property
-
- ' The CellStyle property shows how a property that return a custom
- ' object appears in the Properties window
-
- Dim m_CellStyle As New CellStyle()
-
- Property CellStyle() As CellStyle
- Get
- Return m_CellStyle
- End Get
- Set(ByVal Value As CellStyle)
- m_CellStyle = Value
- End Set
- End Property
-
- End Class
-
- ' This is a custom class used to demonstrate the CellStyle property
-
- Public Class CellStyle
-
- Dim m_ForeColor As System.Drawing.Color
- Dim m_BackColor As System.Drawing.Color
-
- Property ForeColor() As Drawing.Color
- Get
- Return m_ForeColor
- End Get
- Set(ByVal Value As Drawing.Color)
- m_ForeColor = Value
- End Set
- End Property
-
- Property BackColor() As Drawing.Color
- Get
- Return m_BackColor
- End Get
- Set(ByVal Value As Drawing.Color)
- m_BackColor = Value
- End Set
- End Property
- End Class
-